-- By ScatmanJosh --

-- Init --
include( "Xenox_Blocked.lua" )
include( "Xenox_Friends.lua" )
include( "Xenox_Ownership.lua" )
include( "Xenox_Betafunction.lua" )
include( "Xenox_Sourpatch.lua" )

AddCSLuaFile( "Xenox_umsg.lua" )

XEN = XEN or {}

-- Convars --
local blockspawn = CreateConVar( "xenox_antispawn", "0", FCVAR_SERVER_CAN_EXECUTE, "Turns anti-spawn( blocks spawning ) on or off( 1 / 0 )." )

-- Functions --
function XEN.CanTool( ply, tool, ent )
	
end

function XEN.CanPickup( ply, ent )
	
end

local function AddToBlacklist( ply, cmd, args )
	PrintTable( args )
	XEN.Block.AddModel( args[1] )
end

concommand.Add( "add_to_blacklist", AddToBlacklist )

-- Hooks --
hook.Add( "PlayerSpawnObject", "XENOXObjectSpawn", function( ply )
	if blockspawn:GetInt() == 1 then
		XEN.PrintPlayer( ply, "Anti-spawn is currently enabled." )
		return false
	else return true end
end )

hook.Add( "PlayerSpawnProp", "XENOXPropSpawn", function( ply, mdl )
	if XEN.Block.IsBlocked( mdl ) then --NEEDS FILTER: CanBypassModelBlock
		XEN.ChatPlayer( ply, mdl.." is on the blacklist.", Vector( 166, 0, 0 ) )
		return false
	else return true end
end )

hook.Add( "PlayerSpawnedProp", "XENOXPropSpawned", function ( ply, mdl, ent )
	ent:SetPlayerOwner( ply )
	XEN.PrintAll( "Player "..ply:Nick().." spawned "..ent:GetClass()..", model "..mdl..". ( "..ent:GetPlayerOwner():Nick().." )" )
end )